/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.itintegration.catalogue.gui.ejb;

import java.sql.Timestamp;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import lombok.extern.slf4j.Slf4j;
import se.sll.itintegration.catalogue.gui.entity.UserEntity;

/**
 *
 * @author khaleddaham
 */
@Slf4j
public class UserEjb {

    @PersistenceContext(name = "guiPU")
    private EntityManager em;

    public UserEntity update(UserEntity p) {
        Timestamp timestamp = this.getTimeStamp();
        p.setCreationTime(timestamp);
        em.persist(p);
        em.flush();
        em.clear();
        return p;
    }

    private Timestamp getTimeStamp() {
        java.util.Date date = new java.util.Date();
        return new Timestamp(date.getTime());
    }
}